﻿@model CloudFranceTriple.Models.PollSet

@{
    ViewBag.Title = CloudFranceTriple.WebRole.Properties.Resources.PollCreateTitle;
    Layout = "~/Views/Shared/_Layout.cshtml";
}
<div class="content-padding">
    <h1>
        @CloudFranceTriple.WebRole.Properties.Resources.PollCreateTitle
    </h1>
    <section>
        @using (Html.BeginForm())
        {
            @Html.AntiForgeryToken()
            @Html.ValidationSummary(true)

            <fieldset>
                <legend>@CloudFranceTriple.WebRole.Properties.Resources.PollCreateTitle</legend>

                <input type="hidden" id="OrderPoll" name="OrderPoll" value="0" />
                <input type="hidden" id="ForumTopic_Id" name="ForumTopic_Id" value="@ViewBag.Topic_Id" />
                @Html.HiddenFor(model => model.IsRecruitPoll)


                <div class="editor-label">
                    @CloudFranceTriple.WebRole.Properties.Resources.TopicLabel
                </div>
                <div class="editor-field">
                    @ViewBag.TopicLabel
                </div>

                <div class="editor-label">
                    @CloudFranceTriple.WebRole.Properties.Resources.PollLabel
                </div>
                <div class="editor-field">
                    @Html.EditorFor(model => model.LabelPoll)
                    @Html.ValidationMessageFor(model => model.LabelPoll)
                </div>

                <div class="editor-label">
                    @CloudFranceTriple.WebRole.Properties.Resources.PollCreationDate
                </div>
                <div class="editor-field">
                    <input type="text" readonly="true" id="CreationDatePoll" name="CreationDatePoll" value="@DateTime.UtcNow.ToShortDateString()" />
                </div>

                <div class="editor-label">
                    @CloudFranceTriple.WebRole.Properties.Resources.PollDescription
                </div>
                <div class="editor-field">
                    <textarea id="DescriptionPoll" name="DescriptionPoll">
                        @Html.DisplayTextFor(model => model.DescriptionPoll)
                    </textarea>
                    @Html.ValidationMessageFor(model => model.DescriptionPoll)
                </div>

                <div class="editor-label">
                    @CloudFranceTriple.WebRole.Properties.Resources.PollIsPublicPollResult
                </div>
                <div class="editor-field">
                    @Html.CheckBoxFor(model => model.IsPublicPollResult, new { @checked = "true" })
                    @Html.ValidationMessageFor(model => model.IsPublicPollResult)
                </div>

                @if (User.IsInRole("RoleMember"))
                {
                    <div class="editor-label">
                        @CloudFranceTriple.WebRole.Properties.Resources.PollIsMemberOnlyPoll
                    </div>
                    <div class="editor-field">
                        @Html.CheckBoxFor(model => model.IsMemberOnlyPoll)
                        @Html.ValidationMessageFor(model => model.IsMemberOnlyPoll)
                    </div>
                }
                else
                {
                    <div class="display-label">
                        @CloudFranceTriple.WebRole.Properties.Resources.PollIsMemberOnlyPoll
                    </div>
                    <div class="display-field">
                        @Html.DisplayFor(model => model.IsMemberOnlyPoll, new { @checked = "false" })
                        @Html.HiddenFor(model => model.IsMemberOnlyPoll, new { @checked = "false" })
                    </div>
                }

                <div class="editor-field">
                    <div>
                        <input type="text" readonly="true" id="DurationInDays" name="DurationInDays" value="@Model.DurationInDays" style="width: 30px;" />
                        <b>@CloudFranceTriple.WebRole.Properties.Resources.PollDurationInDays</b>
                    </div>
                    <br />
                    <div id="DurationInDaysSlider" style="width: 300px;"></div>
                    <br />
                </div>

                <p>
                    <input type="submit" value="@CloudFranceTriple.WebRole.Properties.Resources.ButtonCreate" />
                </p>
            </fieldset>
        }
        @Html.Partial("_PollBackToPostListByTopic")

        <script type="text/javascript">
            $(function () {
                $("#DurationInDaysSlider").slider(
                {
                    orientation: "horizontal",
                    min: 1,
                    max: 30,
                    value: '@Model.DurationInDays',
                    slide: function (event, ui) {
                        $("#DurationInDays").val(ui.value);
                    },
                });
            });
        </script>
        <script type="text/javascript" src="http://tinymce.cachefly.net/4.0/tinymce.min.js"></script>
        <script type="text/javascript">tinymce.init({ selector: "textarea#DescriptionPoll" });</script>
        @section Scripts {
            @Scripts.Render("~/bundles/jqueryval")
        }
    </section>
</div>
